﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Zbus.Mq;

namespace Api.Example
{
    public class MyService : IService
    {
        public string echo(string msg)
        {
            return msg;
        }

        public string testEncoding()
        {
            return "中文";
        } 

        public void noReturn()
        {

        }

        public int plus(int a, int b)
        {
            return a + b;
        } 

        public void throwException()
        {
            throw new NotImplementedException();
        }

        public Task<string> getString(string req)
        {
            return Task.Run(() =>
            { 
                return "AsyncTask: " + req;
            });
        } 

        public Message redirect()
        {
            Message msg = new Message();
            msg.Status = 302;
            msg.Headers["location"] = "/";
            return msg;
        }

        public Message raw(int i, Message req)
        {
            Message msg = new Message();
            msg.Status = 200;
            msg.BodyString = req.Topic + ":" + i;
            return msg;
        }
    }
}


